//
//  YYManager.m
//  iOS
//
//  Created by LiuHe@MacMini on 14-7-15.
//  Copyright (c) 2014年 cloudyoo. All rights reserved.
//

#import "APPManager.h"
#import "AHReach.h"
//#import "MobClick.h"

@interface APPManager()

@property (nonatomic, strong) AHReach     *reachability;

@end

@implementation APPManager

static APPManager *manager = nil;

+(APPManager *)shareManager
{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        if (!manager) {
            manager = [[APPManager alloc]init];
        }
    });
    return manager;
}

+(id)allocWithZone:(NSZone *)zone{
    @synchronized(self){
        if (!manager) {
            manager = [super allocWithZone:zone];
        }
    }
    return manager;
}

-(void)loadManager{
    static BOOL beLoadManager = YES;
    if (!beLoadManager) {
        return;
    }
    
    //保证该加载过程只会执行一次
    beLoadManager = NO;
    
    //网络状态监测
    [self networkObserve];
    
    //友盟设置
    [self umentInit];
}

#pragma mark - network check
-(void)networkObserve{
    _reachability = [AHReach reachForDefaultHost];
    [_reachability startUpdatingWithBlock:^(AHReach * reach) {
        [Data setTempData:[NSNumber numberWithBool:[reach isReachable]] forKey:app_config_networkstatus];
    }];
}

#pragma mark -umeng settting
-(void)umentInit
{
//    [MobClick startWithAppkey:UMENG_APPKEY reportPolicy:REALTIME   channelId:nil];  //默认appstore 渠道
//    
//    NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
//    [MobClick setAppVersion:version];
    
}



@end
